package net.mingsoft.basic.filter;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import org.apache.commons.text.*;
import java.io.*;

public class XssStringJsonSerializer extends JsonSerializer<String>
{
    public Class<String> handledType() {
        return String.class;
    }
    
    public void serialize(final String value, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException {
        if (value != null) {
            final String encodedValue = StringEscapeUtils.escapeHtml4(value);
            jsonGenerator.writeString(encodedValue);
        }
    }
}
